package com.cheche.dn.domain.user;

import com.cheche.dn.common.base.BaseEntity;
import com.fasterxml.jackson.annotation.JsonProperty;
import org.hibernate.validator.constraints.NotEmpty;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Transient;

/**
 * Entity - User
 * Created by cheshun on 15/8/21.
 */
@Entity
@Table(name = "user")
public class User extends BaseEntity {
    private static final long serialVersionUID = 3555550719494577709L;

    /** "用户名"属性名 */
    public static final String USERNAME_PROPERTY_NAME = "username";

    private String username;        // 用户名
    private String password;        // 密码
    private String nickname;        // 昵称
    private String avatar;          // 头像

    @JsonProperty
    @NotEmpty(groups = Save.class)
    @Column(length = 30, unique = true)
    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    @NotEmpty(groups = Save.class)
    @Column(length = 128)
    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    @JsonProperty
    @NotEmpty(groups = Save.class)
    @Column(length = 50)
    public String getNickname() {
        return nickname;
    }

    public void setNickname(String nickname) {
        this.nickname = nickname;
    }

    @JsonProperty
    @Column(length = 200)
    public String getAvatar() {
        return avatar;
    }

    public void setAvatar(String avatar) {
        this.avatar = avatar;
    }
}
